  {extend name="Public:base" /}
  
        {block name="seo"}
        <title>我的信息页|{$Think.CONFIG.WEB_SITE_TITLE} - Powered by EasySNS!</title>
  
  
  <meta name="keywords" content="{$Think.CONFIG.WEB_SITE_KEYWORD}">
  <meta name="description" content="{$Think.CONFIG.WEB_SITE_DESCRIPTION}">
      {/block}
  
  {block name="body"}
   <link rel="stylesheet" type="text/css" href="__PUBLIC__/js/webuploader/webuploader.css">
   <style>
.webuploader-pick {
    color: #fff;
    text-shadow: 0 -1px 0 rgba(0, 0, 0, .2);
    background-color: #18ab7a;
    border-color: #18ab7a;
    padding:10px 30px;
}
.webuploader-pick-hover,.webuploader-pick:hover {
    color: #fff;
    text-shadow: 0 -1px 0 rgba(0, 0, 0, .2);
    background-color: #6ebda3;
    border-color: #6ebda3;
}
  </style>
   <link rel="stylesheet" type="text/css" href="__CSS__/setting.css" />
  <div class="aw-container-wrap">
	<div class="container">
		<div class="row">
			<div class="aw-content-wraps clearfix">
				<div class="aw-user-setting">
					<div class="tabbable">
						<ul class="nav nav-tabs aw-nav-tabs active">
<li ><a href="{:es_url('user/setverify')}">申请认证</a></li>
							<li><a href="{:es_url('user/setpass')}">安全设置</a></li>
							<li class="active"><a href="#">设置头像</a></li>
							<li ><a href="{:es_url('user/index')}">基本资料</a></li>
							
							<h2><i class="iconfont icon-shezhi"></i> 用户设置</h2>
						</ul>
					</div>
					
					<div class="tab-content clearfix">

<form class="form-horizontal" id="useravatarform">
<div class="avatar-add">
                <p>建议尺寸168*168，支持jpg、png、gif，最大不能超过30KB</p>
                <div class="upload-img">
                  <div class="layui-box layui-upload-button" style="overflow:hidden;">
             
                 <div class="" style="width:100%;display:block;overflow:hidden">
                  <div class=" " id="flash-upload-wrap" data-url="{:es_url('File/pictureUpload')}"><i class="iconfont icon-ai-up-img"></i> 上传头像</div>
                  <input type="hidden" class="form-control" id="userhead" name="userhead"  value="{$nowuserinfo.userhead}" >
                  
                  </div>

                  
               
             </div>
                </div>
                <img src="{:getheadurl($nowuserinfo['userhead'])}" id="userheadimg">
                <span class="loading"></span>
              </div>
                    <div class="form-group" style="margin-top:10px;">
    <div class="col-sm-5">
      <button type="button" data-name="useravatarform"  data-url="{:es_url('user/setavatarHandle')}" class="btn btn-warning changeinfo"><i class="fa fa-save"></i> 修改头像</button>
    </div>
  </div>
     </form>
	
	</div>

</div>


					</div>
				</div>
			</div>
		</div>

    {/block}
        {block name="js"}
    <script type="text/javascript" src="__PUBLIC__/js/webuploader/webuploader.js"></script>
    {/block}
    {block name="script"}
    <script>
  var  uploader = WebUploader.create({

        // swf文件路径
        swf: "__PUBLIC__" + '/js/webuploader/Uploader.swf',
        
        // 文件接收服务端。
        server: $('#flash-upload-wrap').data('url'),
        auto:true,
        fileNumLimit:1,
        //fileSingleSizeLimit:2048000,
       // chunked:true,
        // 选择文件的按钮。可选。
        // 内部根据当前运行是创建，可能是input元素，也可能是flash.
        pick: '#flash-upload-wrap',

        // 不压缩image, 默认如果是jpeg，文件上传前会压缩一把再上传！
        resize: false
    });
    //uploader.on( 'fileQueued', function( file ) {
       // $('.bd').append( '<div id="' + file.id + '" class="item">' +
           // '<h4 class="info">' + file.name + '</h4>' +
           // '<p class="state">等待上传...</p>' +
        //'</div>' );
    //});

    // 文件上传过程中创建进度条实时显示。
    uploader.on( 'uploadProgress', function( file, percentage ) {
        
        //$('.progress').show();
       // $('#progressbar').css( 'width', percentage * 100 + '%' );
        //$('#progressbar').html(percentage * 100 + '%' );
    });
    uploader.on( 'uploadSuccess', function( file,response ) {

    
    	if(response.code==0){
    		layer.msg(response.errormsg, {icon: 2, time: 1000}, function(){
    			uploader.reset();
            });
    	}else{
    		layer.msg('上传成功', {icon: 1, time: 1000}, function(){

    			 $('#userheadimg').attr('src',response.headpath);
    			 $('#userhead').val(response.userheadpath);
            });
    	}
    	
    	
    });
    uploader.on( 'uploadError', function( file,reason ) {
    	console.log(reason);
    	layer.msg('上传出错', {icon: 2, time: 1000}, function(){
    		uploader.reset();
        });
    });
    uploader.on( 'error', function(reason ) {
    	var msg;
    	layer.msg('上传出错代码'+reason, {icon: 2, time: 1000}, function(){
    		uploader.reset();
        });
    	//if(reason=='F_EXCEED_SIZE'){
    		//msg='';
    	//}
    });

    uploader.on( 'uploadComplete', function( file ) {
    	//$('.progress').fadeOut();
    });
    $(function(){
    	
    	$('.changeinfo').click(function(){
    		var formname=$(this).data('name');
		    $.post($(this).data('url'),$('form#'+formname).serialize(),function(data){
			    
		    	
		    	
		    	
			      if(data.code == 1){
				        
				        layer.msg(data.msg, {icon: 1, time: 1000}, function(){
				          location.reload();
				        });
				      }else{
				        
				        layer.msg(data.msg, {icon: 2, anim: 6, time: 1000});
				        
				        
				        
				   }
			
	    	

	    });
	    return false;
    		
    		
    		
    		
    		
    	});
    	
    })
    </script>
    {/block}